-
Notifications
You must be signed in to change notification settings - Fork 620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #577
Solution #577
Conversation
if ((not (4 <= self.age <= 14)) | ||
or (not (20 <= self.weight <= 50)) | ||
or (not (80 <= self.height <= 120))): | ||
return False | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DRY
def validate(self) -> bool: | ||
if (not (14 <= self.age <= 60) | ||
or not (50 <= self.weight <= 120) | ||
or not (120 <= self.height <= 220)): | ||
return False | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DRY
don't repeat yourself
try: | ||
self.limitation_class(visitor.age, | ||
visitor.weight, | ||
visitor.height) | ||
except ValueError: | ||
... | ||
obj = self.limitation_class(visitor.age, | ||
visitor.weight, | ||
visitor.height) | ||
return obj.validate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try: | |
self.limitation_class(visitor.age, | |
visitor.weight, | |
visitor.height) | |
except ValueError: | |
... | |
obj = self.limitation_class(visitor.age, | |
visitor.weight, | |
visitor.height) | |
return obj.validate() | |
try: | |
self.limitation_class( | |
visitor.age, | |
visitor.weight, | |
visitor.height | |
) | |
except (TypeError, ValueError): | |
return False | |
return True |
limitation_class: [ChildrenSlideLimitationValidator, | ||
AdultSlideLimitationValidator]) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
limitation_class: [ChildrenSlideLimitationValidator, | |
AdultSlideLimitationValidator]) -> None: | |
limitation_class: Type[SlideLimitationValidator]) -> None: |
"""if not (self.min_amount <= value <= self.max_amount): | ||
raise ValueError("ValueError")""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""if not (self.min_amount <= value <= self.max_amount): | |
raise ValueError("ValueError")""" | |
if not isinstance(value, int): | |
raise TypeError("message") | |
if not (self.max_amount >= value >= self.min_amount): | |
raise ValueError("message") |
No description provided.